const BaseIpcHandler = require('../BaseIpcHandler');

class ClearQueueHandler extends BaseIpcHandler {
    async handle(event, params) {
        // 解析参数
        // console.log(`>> [${timestamp}] ClearQueueHandler params = `, params);
        const { task_id } = params;

        // 业务逻辑
        let result = this.app.queue.clear(task_id);
        result = { code: 0, msg: result };

        // 返回结果
        if (event.from === 'localserver') {
            event.resp.send(result);
        } else {
            return result;
        }
    }
}

module.exports = ClearQueueHandler;
